package com.hm.service.controller.manage;

import com.hm.service.framework.request.post.PostBase;
import com.hm.service.framework.request.post.PostHandleBean;
import jakarta.servlet.http.HttpServletRequest;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


@RestController
@RequestMapping(value = "/Manage", produces = {"application/json;charset=UTF-8"})
public class CFSS_000_000_101 {

    private static final Logger logger = LoggerFactory.getLogger(CFSS_000_000_101.class);

    //获取session接口
    @PostMapping(value = "/000_000_101")
    public String doPost(HttpServletRequest request) {
        try {
            String sessionId = request.getHeader("sessionId");
            String body = request.getReader().readLine();
            logger.error("hm-sessionId->" + sessionId);
            logger.error("hm-body->" + body);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        return "请求成功";
    }


    public static void main(String[] args) {

        String appid = "wxac6a79620dda135c";
        String secret = "5a4bd6816f0beb39c854a08a490f01c0";
        String js_code = "0f1eUvFa1r6jMG0oT3Ja1PDTG33eUvF7";

        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder().url("https://api.weixin.qq.com/sns/jscode2session?appid=" + appid + "&secret=" + secret + "&js_code=" + js_code + "&grant_type=authorization_code").build();

        try {
            Response response = okHttpClient.newCall(request).execute();
            String string = response.body().string();
            logger.error("ResponseBody:" + string);
        } catch (IOException e) {
            logger.error("IOException:" + e.getMessage());
        }
    }


}
